<?php
namespace Admin\Controller;
use Admin\Controller\CommonController;
class ShowController extends CommonController {
 
    	
  //===================================产品订单


     public function huxing(){

        $huxing = M('zlist');
        $count = M('zlist')->count();
  
        $Page =new \Think\Page($count,10);
        $Page -> setConfig('first','首页');
        $Page -> setConfig('last','末页');
        $Page -> setConfig('prev','上一页');
        $Page -> setConfig('next','下一页');
        $Page -> setConfig('theme',' <div style="margin-top:2px">  %FIRST%  %UP_PAGE%    %LINK_PAGE%  %DOWN_PAGE%   %END% </div> ');



        $show = $Page->show();


        $list = $huxing->order('id desc')->limit($Page->firstRow, $Page->listRows)->select();
        $this->assign('huxing',$list);
    $this->assign("page",$show);

        $this->display();
     }




public function huxingdel(){
        $id = I('get.id');
        if ($id>0) {
            M('zlist')->where(array('id'=>$id))->delete();
                   
            //M('zixun')->where(array('type'=>$id))->delete();

            $this->redirect('Show/huxing');
            exit();
            # code...
        }


     }



        
    /**
     +----------------------------------------------------------
     * 添加管理员
     +----------------------------------------------------------
     */
    Public function addlist(){
        if(IS_POST){
                    

            $data=array();
            $data=I('post.');  

            $result=M('zlist')->where('yanse="'.trim($data['yanse']).'"')->find();

            if ($result) {
                $this->error('颜色已存在',U('Show/huxing'));
            }else{
            if(M('zlist')->add($data)){
                //$this->success('添加成功',U('Show/huxing'));
                $this->redirect('Show/huxing');
                exit();
            }else{
                $this->success('添加失败',U('Show/huxing'));
                exit();
            }

}

        }




        $this->display();
    }





    Public function addhuxing(){
        if(IS_POST){
                    

            $data=array();
            $data=I('post.');



            if(M('zlist')->add($data)){
                $this->success('分类添加成功',U('Show/huxing'));
                exit();
            }else{
                $this->success('分类添加失败',U('Show/huxing'));
                exit();
            }



        }




        $this->display();
    }



     public function fenlei() {

            $id=I('get.id');
            $zi=M('zlist');
            $map['id']=$id;



            $info=$zi->where($map)->find();
          
        


            $this->assign('info',$info);
    
  
      
        if (IS_POST) {
           
            $data=I('post.');

            $id=I('get.id');
            if(M('zlist')->where("id=".$data['dd'])->data($data)->save()){
                // $this->success('修改成功',U('Show/huxing'));
              $this->redirect('Show/huxing');
            }else{
                $this->success('修改失败',U('Show/huxing'));
            }
        } else {
        
            $this->display();
        }
    }
    

    Public function addks(){
        if(IS_POST){
                    

            $data=array();
            $data=I('post.');  

            $result=M('kuanshi')->where('ks_name="'.trim($data['ks_name']).'"')->find();

            if ($result) {
                $this->error('款式名称已存在',U('Show/kuanshi'));
            }else{
            if(M('kuanshi')->add($data)){
                //$this->success('添加成功',U('Show/huxing'));
                $this->redirect('Show/kuanshi');
                exit();
            }else{
                $this->success('添加失败',U('Show/kuanshi'));
                exit();
            }

}

        }




        $this->display();
    }



     public function kuanshi(){

         $huxing = M('kuanshi');
        $count = M('kuanshi')->count();
  
        $Page =new \Think\Page($count,10);
        $Page -> setConfig('first','首页');
        $Page -> setConfig('last','末页');
        $Page -> setConfig('prev','上一页');
        $Page -> setConfig('next','下一页');
        $Page -> setConfig('theme',' <div style="margin-top:2px">  %FIRST%  %UP_PAGE%    %LINK_PAGE%  %DOWN_PAGE%   %END% </div> ');



        $show = $Page->show();


        $list = $huxing->order('id desc')->limit($Page->firstRow, $Page->listRows)->select();
        $this->assign('kuanshi',$list);
        $this->assign("page",$show);



               $this->display();
     }


  public function kuanshidel(){
        $id = I('get.id');
        if ($id>0) {
            M('kuanshi')->where(array('id'=>$id))->delete();
                   
            //M('zixun')->where(array('type'=>$id))->delete();

            $this->redirect('Show/kuanshi');
            exit();
            # code...
        }


     }


     public function ksfenlei() {

            $id=I('get.id');
            $zi=M('kuanshi');
            $map['id']=$id;



            $info=$zi->where($map)->find();
          
        


            $this->assign('info',$info);
    
  
      
        if (IS_POST) {
           
            $data=I('post.');

            $id=I('get.id');
            if(M('kuanshi')->where("id=".$data['dd'])->data($data)->save()){
                // $this->success('修改成功',U('Show/huxing'));
              $this->redirect('Show/kuanshi');
            }else{
                $this->success('未修改',U('Show/kuanshi'));
            }
        } else {
        
            $this->display();
        }
    }


}

?>